<%= form_with model: [:settings, user], class: "tabular-form" do |form| %>

  <%= text_input_row form, :username %>
  <%= text_input_row form, :email %>

  <% if !user.persisted? %>
    <% if SiteSettings.email_configured? %>
      <div></div>
      <div class="alert alert-info">
        <%= t(".password_reset_help") %>
      </div>
    <% else %>
      <%= password_input_row form, :password %>
      <%= password_input_row form, :password_confirmation %>
    <% end %>
  <% end %>

  <div>
    <%= form.label :roles, class: "col-auto col-form-label" %>
  </div>
  <div>
    <%= form.collection_check_boxes :role_ids, @available_roles, :id, :name do |b| # rubocop:disable Pundit/UsePolicyScope
          content_tag :div, class: "form-check" do
            b.check_box(class: "form-check-input") +
              b.label(class: "form-check-label")
          end
        end %>
  </div>

  <% if SiteSettings.enable_user_quota %>
    <h3><%= t("settings.users.quota.title") %></h3>
    <%= checkbox_input_row form, :quota_use_site_default, label: t("settings.users.quota.using_site_default") %>
    <%= numeric_input_row form, :quota,
          label: t("settings.users.quota.current_quota"),
          min: 0, step: 1,
          unit: "MB",
          value: (user.quota.to_i / 1.megabyte) %>
  <% end %>

  <div>
    <%= form.submit translate(".submit"), class: "btn btn-primary" %>
  </div>

<% end %>
